package com.echoplots.jpa.config;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
/**
 * 
 * @author cos
 * @desc 区分两个数据的DataSource配置类
 */
@Configuration
public class DataSourceConfig {
	@Bean
    @ConfigurationProperties(prefix = "spring.datasource.druid.master")
    @Primary
    DataSource dsMaster(){
        return DruidDataSourceBuilder.create().build();
    }

    @Bean
    @ConfigurationProperties(prefix = "spring.datasource.druid.slave")
    DataSource dsSlave(){
        return DruidDataSourceBuilder.create().build();
    }
}
